<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;
use OT\DataDictionary;

/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class IndexController extends HomeController {

	//系统首页
    public function index(){

//        $category = D('Category')->getTree();
//        $lists    = D('Document')->lists(null);

//        $this->assign('category',$category);//栏目
//        $this->assign('lists',$lists);//列表
//        $this->assign('page',D('Document')->page);//分页

        //头部数据
        $wherenav=array(
            'language' => 0,
            'parentid' => 0
        );
        $nav=M('navigator')
            ->where($wherenav)
            ->order('sort')
            ->select();
        foreach ($nav as $key=>$value){
            $nav[$key]['list']=M('navigator')->where(array('parentid'=>$value['id']))->select();
        }
        $this->assign('nav',$nav);
        //头部数据

        //banner
		$banner=M('indexbanner')
                ->order('sort')
                ->select();
		$this->assign('banner',$banner);

		$product=M('product')
                ->where(array('index'=>0))
                ->select();
        $this->assign('product',$product);

        $news=M('news')
            ->where(array('index'=>0))
            ->field('id,title,time')
            ->order('sort desc')
            ->limit(6)
            ->select();
        $this->assign('news',$news);
        $this->assign('newsempty','<li><a href="#">暂无数据</a><span>-- -- --</span></li>');


        //左下方数据
        $leftdata=M('indexleft')->find();
        $this->assign('leftdata',$leftdata);
        //左下方数据

        //右下方数据
        $rightdata=M('slider')->select();
        $this->assign('rightdata',$rightdata);
        //右下方数据
        $this->display();
    }

}